<?php
/**
 * Created by litong on Date: 2018/12/22 0022 下午 4:08
 */
$arr1=array("VOLVO","BMW","TOYOTA");
echo "i like ".$arr1[0].",".$arr1[1].",".$arr1[2];
// 手动设置数组下标
$arr2[0]="volvo";
$arr2[1]="BMW";
$arr2[2]="TOYOTA";

// 获取数组的长度
$arr2Count=count($arr2);
echo "长度是:$arr2Count";

echo "开始遍历数组";
$arr3=array("volvo","bmw","toyota");
$length=count($arr3);
for($i=0;$i<$length;$i++){
  echo $arr3[$i],PHP_EOL;
}

$age=array("Petter"=>"35","Ben"=>"37","Joe"=>"43");
foreach ($age as $x=>$x_value) {
  echo "<br/>";
  echo "key=".$x."value=".$x_value;
}

// 数组排序
$a=array("key1"=>"val1","key6"=>"val6","key3"=>"val1","key5"=>"val6","key4"=>"val8");
echo "sort (\$a)=".PHP_EOL;
sort($a);
var_dump($a);
?>
